*****STATA CODE FOR CREATING THE TABLES AND FIGURES IN 
*****Bhalotra, Clots-Figueras, Iyer and Vecci. Leader Identity and Coordination. Review of Economics and Statistics.

set more off
global path "/users/liyer/dropbox/Religious_identity_experiment/Data/ReplicationData"
cd $path

**Set up controls
global demographics "male age caste_scst caste_obc edu_grade10 edu_grade12 edu_tertiary inc_5to10k inc_10to15k inc_15to30k inc_more30k"
global experiment "LeaderPropP min_effort_r4"
global experiment2 "min_effort_r4"
global religious "pray_dayonce pray_daymany"

cap log close
log using BCIV_ReplicationData_Regressions.log, text replace

use BCIV_ReplicationData.dta, clear


***************************************************************
*** Figure 1a, 1b, 1c
***************************************************************
preserve
collapse (mean) MinEffortP LeaderProp (mean) meaneffort= MinEffortP (sd) sdeffort=MinEffortP (count) n=MinEffortP, by(treatment mleader period)

generate hieffort = meaneffort + invttail(n-1,0.025)*(sdeffort / sqrt(n))
generate loweffort = meaneffort - invttail(n-1,0.025)*(sdeffort / sqrt(n))


****Fig 1a: Muslim vs Hindu led groups
twoway (line MinEffortP period if mleader==1 & treatment==1 , lpattern(solid) lcolor(maroon)) ///
       (rcap hieffort loweffort period if mleader==1 & treatment==1, lcolor(maroon) ) ///
  (line MinEffortP period if mleader==0 & treatment==1 , lpattern(dash) lcolor(blue)) ///
  (rcap hieffort loweffort period if mleader==0 & treatment==1, lcolor(blue) ) ,  ///
ytitle(Minimum Effort)  legend(label(1 "Muslim leader") label(2 "95% confidence interval") label(3 "Hindu leader") label(4 "95% confidence interval") size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("A. Control Group")

graph export "$path/f1a.png", as(png) replace


***Fig 1b: Muslim leaders across different treatments

twoway (line MinEffortP period if mleader==1 & treatment==1 , lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==1, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==1 & treatment==2 , lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==2, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==1 & treatment==3 , lpattern(shortdash) lcolor(dkgreen))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==3, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.")   size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("B. Muslim Leader")

graph export "$path/f1b.png", as(png) replace

***Fig 1c: Hindu leaders across different treatments

twoway (line MinEffortP period if mleader==0 & treatment==1 , lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==0 & treatment==1, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==0 & treatment==2 , lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if mleader==0 & treatment==2, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==0 & treatment==3 , lpattern(shortdash) lcolor(dkgreen))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==3, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.")   size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("C. Hindu Leader")

graph export "$path/f1c.png", as(png) replace

restore

***************************************************************
***Figure 2a, 2b, 2c, 2d
***************************************************************

preserve 
collapse (mean) MinEffortP LeaderProp (mean) meaneffort= MinEffortP (sd) sdeffort=MinEffortP (count) n=MinEffortP, by(treatment mleader period highconflict)

generate hieffort = meaneffort + invttail(n-1,0.025)*(sdeffort / sqrt(n))
generate loweffort = meaneffort - invttail(n-1,0.025)*(sdeffort / sqrt(n))

****2a. Muslim Led Groups, low conflict areas
twoway (line MinEffortP period if mleader==1 & treatment==1 & highconflict==0, lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==1 & highconflict==0, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==1 & treatment==2 & highconflict==0, lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if  mleader==1 & treatment==2 & highconflict==0, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==1 & treatment==3 & highconflict==0, lpattern(shortdash) lcolor(dkgreen)) ///
		(rcap hieffort loweffort period if mleader==1 & treatment==3 & highconflict==0, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.") size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("A. Muslim Leader, Low Conflict Areas")
graph export "$path/f2a.png", as(png) replace

****2b. Muslim Led Groups, high conflict areas
twoway (line MinEffortP period if mleader==1 & treatment==1 & highconflict==1, lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==1 & treatment==1 & highconflict==1, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==1 & treatment==2 & highconflict==1, lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if  mleader==1 & treatment==2 & highconflict==1, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==1 & treatment==3 & highconflict==1, lpattern(shortdash) lcolor(dkgreen)) ///
		(rcap hieffort loweffort period if mleader==1 & treatment==3 & highconflict==1, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.")  size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("B. Muslim Leader, High Conflict Areas")
graph export "$path/f2b.png", as(png) replace

****2c. Hindu Led Groups, low conflict areas
twoway (line MinEffortP period if mleader==0 & treatment==1 & highconflict==0, lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==0 & treatment==1 & highconflict==0, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==0 & treatment==2 & highconflict==0, lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if  mleader==0 & treatment==2 & highconflict==0, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==0 & treatment==3 & highconflict==0, lpattern(shortdash) lcolor(dkgreen)) ///
		(rcap hieffort loweffort period if mleader==0 & treatment==3 & highconflict==0, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.")  size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("C. Hindu Leader, Low Conflict Areas")
graph export "$path/f2c.png", as(png) replace

****2d. Hindu Led Groups, high conflict areas
twoway (line MinEffortP period if mleader==0 & treatment==1 & highconflict==1, lpattern(solid) lcolor(maroon))  ///
		(rcap hieffort loweffort period if mleader==0 & treatment==1 & highconflict==1, lcolor(maroon)) ///	
	   (line MinEffortP period if mleader==0 & treatment==2 & highconflict==1, lpattern(longdash_dot) lcolor(blue))  ///
		(rcap hieffort loweffort period if  mleader==0 & treatment==2 & highconflict==1, lcolor(blue)) ///	
	   (line MinEffortP period if mleader==0 & treatment==3 & highconflict==1, lpattern(shortdash) lcolor(dkgreen)) ///
		(rcap hieffort loweffort period if mleader==0 & treatment==3 & highconflict==1, lcolor(dkgreen)), ///	
ytitle(Minimum Effort)  legend(label(1 "Control") label(2 "95% C.I.") label(3 "AA") label(4 "95% C.I.") label(5 "Intergroup Contact") label(6 "95% C.I.")  size(medium))  xline(4, lcolor(black) lpattern(solid))  ///
xtitle(Period) 	xlabel(1(1)6) ylabel(2(1)7) name(panelb, replace) bgcolor(white) graphregion(color(white)) title("D. Hindu Leader, High Conflict Areas")
graph export "$path/f2d.png", as(png) replace

restore


***********************************************************************************
**T1: Leader Identity and Minimum Effort (Control group)
***********************************************************************************

cap erase "$path/t1.xls"

preserve
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen mleader_p56=mleader*leader
gen hleader_p56=(1-mleader_p56)*leader 

label var mleader_p56 "Muslim leader*(period>4)"

**Column 1: Effect of a Muslim leader, no controls
areg MinEffortP  leader  if  treatment==1 & mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t1.xls", bdec(3) excel ctitle("Muslim Leaders") replace addtext( Town FE, Yes, Demographic Controls, No, Religious Controls, No, Experimental Controls, No) 

**Column 2: Effect of a Hindu leader, no controls
areg MinEffortP  leader  if  treatment==1 & hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t1.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, No, Religious Controls, No, Experimental Controls, No) 


**Column 3: Effect of a Muslim leader,controls
areg MinEffortP  leader $demographics $religious  if  treatment==1 & mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t1.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 4: Effect of a Hindu leader, controls
areg MinEffortP  leader $demographics $religious  if  treatment==1 & hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t1.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 5: Interacted Spec with Leader and Muslim Leader dummies to show that the difference is statistically significant (all rounds)
areg MinEffortP  leader mleader_p56 mleader $demographics $religious  if  treatment==1 , vce(cl unique_groupid)  absorb(townid_exp)

outreg2 leader  mleader_p56 mleader using "$path/t1.xls", bdec(3) excel ctitle("All Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 6: Specification for only rounds 5 and 6 with Muslim Leader dummies, but adding experimental controls, in particular leader’s proposal
areg MinEffortP mleader $demographics $religious $experiment if  treatment==1 & period>4, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  mleader_p56 mleader using "$path/t1.xls", bdec(3) excel ctitle("All Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 

***testing whether group minimum effort in period 4 is significantly different from zero, or significantly different from 5
regress MinEffort if period<=4 & treatment==1, robust
regress MinEffort if period==4 & treatment==1, robust
bys mleader: regress MinEffort if period<=4 & treatment==1, robust
bys mleader: regress MinEffort if period==4 & treatment==1, robust
restore
exit

***********************************************************************************
**T2: Leader Identity and Individual effort (control group)
**Dep var: individual effort
***********************************************************************************

gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen interaction=leader*mleader
cap erase "$path/t2.xls"

**Column 1: Hindu leader, Muslim individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==0 & muslim==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t2.xls", bdec(3) excel ctitle("Hindu Leaders, Muslim Employees") replace addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 2: Hindu leader, Hindu individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==0 & muslim==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t2.xls", bdec(3) excel ctitle("Hindu Leaders, Hindu Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 3: Muslim leaders, Muslim individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==1 & muslim==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t2.xls", bdec(3) excel ctitle("Muslim Leaders, Muslim Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 4: Muslim leader, Hindu individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==1 & muslim==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader using "$path/t2.xls", bdec(3) excel ctitle("Muslim Leaders, Hindu Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***testing whether individual responses are different across H and M employees for H and M leaders
foreach var of varlist  leader $demographics $religious {
gen `var'_mus=`var'*muslim
}

tab townid_exp, gen(towndum)
foreach var of varlist towndum* {
gen `var'_mus=`var'*muslim
}

global demographics_mus "male_mus age_mus caste_scst_mus caste_obc_mus edu_grade10_mus edu_grade12_mus edu_tertiary_mus inc_5to10k_mus inc_10to15k_mus inc_15to30k_mus inc_more30k_mus"
global religious_mus "pray_dayonce_mus pray_daymany_mus"

reg EffortP  leader leader_mus $demographics $religious  $demographics_mus $religious_mus  towndum*  if treatment==1 & mleader==0 , vce(cl unique_groupid)
reg EffortP  leader leader_mus $demographics $religious $demographics_mus $religious_mus towndum* if treatment==1 & mleader==1 , vce(cl unique_groupid)

***********************************************************************************
**T3: Policy Environments and Leader Effectiveness
**Dependent variable: Minimum effort in group (group level regressions)
***********************************************************************************

preserve
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen mleader_p56=mleader*leader
label var mleader_p56 "Muslim leader*(period>4)"
gen leader_aa=leader*(treatment==2)
gen leader_contact=leader*(treatment==3)

cap erase "$path/t3.xls"

**Column 1: Muslim leaders
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t3.xls", bdec(3) excel ctitle("Muslim Leaders") replace addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

**Column 2: Hindu leaders
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t3.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

**Column 3: Muslim leaders with experimental controls (no town effects)
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if mleader==1 & period>4, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/t3.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 
lincom leader_aa-leader_contact

**Column 4: Hindu leaders with experimental controls (no town effects)
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if hleader==1 & period>4, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/t3.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 
lincom leader_aa-leader_contact
restore

***********************************************************************************
**T4: Does a History of Conflict Matter for Leader Effectiveness  across Policy Environments?
***********************************************************************************

preserve
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment highconflict $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"

gen leader_aa=leader*(treatment==2)
gen leader_contact=leader*(treatment==3)

cap erase "$path/t4.xls"

***Column 1: Muslim leader,low conflict
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if mleader==1 & highconflict==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t4.xls", bdec(3) excel ctitle("Muslim Leaders, Low Conflict Areas") replace addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***Column 2: Muslim leader, high conflict
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if mleader==1 & highconflict==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t4.xls", bdec(3) excel ctitle("Muslim Leaders, High Conflict Areas") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***Column 3:Hindu leader,low conflict
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if mleader==0 & highconflict==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t4.xls", bdec(3) excel ctitle("Hindu Leaders, Low Conflict Areas") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***Column 4:Hindu leader,high conflict
areg MinEffortP  leader leader_aa leader_contact  $demographics $religious if mleader==0 & highconflict==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  leader_aa leader_contact  using "$path/t4.xls", bdec(3) excel ctitle("Hindu Leaders, High Conflict Areas") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

restore


***********************************************************************************
**TA1: Number of Sites
***********************************************************************************

***********************************************************************************
**TA2: Demographic Characteristics Across Towns in Different Treatment Groups
***********************************************************************************

**Panel A: town characteristics
use BCIV_ReplicationData_townchars.dta, clear
gen contact=(treatment==2)
gen aa=(treatment==3)

foreach var of varlist totpop pmuslim sexratio childsexratio totlit femlit psc pst workpart_male workpart_female workhh_male workoth_male {
regress `var' contact aa, robust
}
tabstat totpop pmuslim sexratio childsexratio totlit femlit psc pst workpart_male workpart_female workhh_male workoth_male,by(treatment)

**Panel B: using the demographic variables from our survey
use BCIV_ReplicationData.dta, clear
gen contact=(treatment==2)
gen aa=(treatment==3)
foreach var of varlist male age caste* edu* inc* pray* {
regress `var' contact aa if period==1, robust
}
tabstat  male age caste* edu* inc* pray* if period==1, by(treatment)

***********************************************************************************
**TA3: Payoff Table
***********************************************************************************

***********************************************************************************
**TA4: Experiment Participant Characteristics Across Groups with Hindu and Muslim Leaders
***********************************************************************************
foreach var of varlist male age caste* edu* inc* pray* {
regress `var' mleader if period==1, robust
}

tabstat  male age caste* edu* inc* pray* if period==1, by(mleader)

***********************************************************************************
**TA5: Summary Statistics of Key Variables
***********************************************************************************
tabstat MinEffortP if mleader==0 & period<=4, by(treatment) column(statistic) s(mean sd)
tabstat MinEffortP if mleader==0 & period>4, by(treatment)  column(statistic) s(mean sd)
tabstat LeaderPropP if mleader==0 & period>4, by(treatment)  column(statistic) s(mean sd)
tabstat EffortP if mleader==0 & muslim==0, by(treatment)  column(statistic) s(mean sd)
tabstat EffortP if mleader==0 & muslim==1, by(treatment)  column(statistic) s(mean sd)

tabstat MinEffortP if mleader==1 & period<=4, by(treatment) column(statistic) s(mean sd)
tabstat MinEffortP if mleader==1 & period>4, by(treatment)  column(statistic) s(mean sd)
tabstat LeaderPropP if mleader==1 & period>4, by(treatment)  column(statistic) s(mean sd)
tabstat EffortP if mleader==1 & muslim==0, by(treatment)  column(statistic) s(mean sd)
tabstat EffortP if mleader==1 & muslim==1, by(treatment)  column(statistic) s(mean sd)

***********************************************************************************
**TA6: Do Leader Proposals Across Leader Identity and Treatment Arms?
***********************************************************************************
preserve
keep if Leader1==1
keep if period>4

gen m_aa=mleader*(treatment==2)
gen m_contact=mleader*(treatment==3)

cap erase "$path/ta6.xls"

***column 1: H vs M, control group (with town FE)
areg LeaderPropP  mleader  $demographics $religious if treatment==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 mleader using "$path/ta6.xls", bdec(3) excel ctitle("Across Leader Identity, Control Group") replace addtext(Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 

***column 2: H vs M leaders, across treatments (with town FE)
areg LeaderPropP  mleader m_aa m_contact   $demographics $religious , vce(cl unique_groupid) absorb(townid_exp) 
outreg2 mleader m_aa m_contact  using "$path/ta6.xls", bdec(3) excel ctitle("Across Treatments, All Leaders") append addtext(Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 

summ LeaderPropP if treatment==1 & mleader==0

restore

***********************************************************************************
**TA7: Alternative Explanations for Higher Coordination in Muslim-led Groups
***********************************************************************************

preserve
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment town_musmayor belief_leader_hrs mnotcapable $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen mleader_p56=mleader*leader
gen hleader_p56=(1-mleader_p56)*leader 

gen leader_musmayor=leader*town_musmayor
gen leader_mnotcapable=leader*mnotcapable

cap erase "$path/ta7.xls"

**Column 1: Effect of a Muslim leader interacted with fraction group agreeing that Muslim leaders are not as capable
areg MinEffortP  leader leader_mnotcapable  mnotcapable  $demographics $religious if  treatment==1 & mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader leader_mnotcapable mnotcapable using "$path/ta7.xls", bdec(3) excel ctitle("Muslim Leaders") replace addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 
lincom leader+leader_mnotcapable

**Column 2: Effect of a Hindu leader interacted with fraction group agreeing that Muslim leaders are not as capable
areg MinEffortP  leader leader_mnotcapable mnotcapable  $demographics $religious if  treatment==1 & hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader leader_mnotcapable  mnotcapable   using "$path/ta7.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 
lincom leader+leader_mnotcapable

**Column 3: Effect of a Muslim leader interacted with whether town had a muslim mayor
areg MinEffortP  leader leader_musmayor $demographics $religious if  treatment==1 & mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader leader_musmayor using "$path/ta7.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 

**Column 4: Effect of a Hindu leader interacted with muslim mayor
areg MinEffortP  leader leader_musmayor $demographics $religious if  treatment==1 & hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader leader_musmayor  using "$path/ta7.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 

***Column 5: Muslim leader, controlling for beliefs about leader hours
areg MinEffortP leader belief_leader_hrs $demographics $religious  if  mleader==1 & treatment==1 , vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  belief_leader_hrs using "$path/ta7.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 

***Column 6:Hindu leader, controlling for beliefs about leader hours
areg MinEffortP leader belief_leader_hrs $demographics $religious  if  mleader==0 & treatment==1 , vce(cl unique_groupid)  absorb(townid_exp)
outreg2 leader  belief_leader_hrs using "$path/ta7.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes) 
restore


***********************************************************************************
**TA8: Leader Identity and Social Appropriateness of High Effort Choices
***********************************************************************************
preserve
keep if period==6

***Hindu respondents
summ socapp_HempHleader socapp_HempMleader socapp_MempHleader socapp_MempMleader if muslim==0 
***Muslim respondents
summ  socapp_HempHleader socapp_HempMleader socapp_MempHleader socapp_MempMleader if muslim==1 

***testing for differences
ttest socapp_HempHleader= socapp_HempMleader if muslim==0 
ttest socapp_MempHleader= socapp_MempMleader if muslim==0 

ttest socapp_HempHleader= socapp_HempMleader if muslim==1
ttest socapp_MempHleader= socapp_MempMleader if muslim==1 

restore

***********************************************************************************
**TA9: Leader Identity and Individual Effort in Different Policy Environments
***********************************************************************************
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"

gen leader_aa=leader*(treatment==2)
gen leader_contact=leader*(treatment==3)

cap erase "$path/ta9.xls"
**Column 1: Muslim leaders, Muslim individuals
areg EffortP  leader leader_aa leader_contact $demographics $religious if mleader==1 & muslim==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2  leader leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Muslim Leaders, Muslim Employees") replace addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

**Column 2: Muslim leader, Hindu individuals
areg EffortP  leader leader_aa leader_contact $demographics $religious if  mleader==1 & muslim==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2  leader leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Muslim Leaders, Hindu Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

**Column 3: Hindu leader, Muslim individuals
areg EffortP  leader leader_aa leader_contact $demographics $religious if mleader==0 & muslim==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2  leader leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Hindu Leaders, Muslim Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

**Column 4: Hindu leader, Hindu individuals
areg EffortP  leader leader_aa leader_contact $demographics $religious if  mleader==0 & muslim==0, vce(cl unique_groupid)  absorb(townid_exp)
outreg2  leader leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Hindu Leaders, Hindu Employees") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
lincom leader_aa-leader_contact

***same regressions, but with experimental controls and no town FE
**Column 5: Muslim leaders, Muslim individuals
reg EffortP leader_aa leader_contact $demographics $religious $experiment if mleader==1 & muslim==1 & period>4, vce(cl unique_groupid)
outreg2 leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Muslim Leaders, Muslim Employees") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 6: Muslim leader, Hindu individuals
reg EffortP  leader_aa leader_contact $demographics $religious  $experiment if  mleader==1 & muslim==0 & period>4, vce(cl unique_groupid)
outreg2  leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Muslim Leaders, Hindu Employees") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 7: Hindu leader, Muslim individuals
reg EffortP  leader_aa leader_contact $demographics $religious  $experiment if  mleader==0 & muslim==1 & period>4, vce(cl unique_groupid)
outreg2  leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Hindu Leaders, Muslim Employees") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 8: Hindu leader, Hindu individuals
reg EffortP  leader_aa leader_contact $demographics $religious  $experiment if  mleader==0 & muslim==0 & period>4, vce(cl unique_groupid)
outreg2  leader_aa leader_contact using "$path/ta9.xls", bdec(3) excel ctitle("Hindu Leaders, Hindu Employees") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 


***********************************************************************************
**FA1, FA2, FA3: Map, pictures
***********************************************************************************
***********************************************************************************
**FA4: Leader Identity and Leader Proposals (Histogram)
***********************************************************************************
tab LeaderPropP muslim if Leader1==1 & (period==5|period==6) & treatment==1 /**bar graph made in Excel**/

***********************************************************************************
**FA5: Muslim Leader Impact and Muslim Population Share (Control Group Towns)
***********************************************************************************
preserve
keep if treatment==1
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment $demographics  $experiment $religious town_pmus, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"

cap erase "$path/fa5.xls"
cap erase "$path/fa5.txt"

foreach num in 5 6 9 11 13 14 17 21 27 30 32 38 40 43 {
reg MinEffortP  leader $demographics $religious if mleader==1 & townid_exp==`num',  vce(cl unique_groupid)  
outreg2 leader using "$path/fa5.xls", bdec(3) excel ctitle("`num'") append  
}

tabstat town_pmus, by(townid_exp)
restore
**graph made in Excel

***********************************************************************************
**TC1: Leader Identity and Effort Choices in the Control Group: Robustness Checks
***********************************************************************************

preserve
collapse (mean) nolike_diffrel highconflict MinEffortP EffortP mleader hleader townid_exp treatment town_pmus $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"

***town random effects
xtset unique_groupid period 

cap erase "$path/tc1.xls"
cap erase "$path/tc1.txt"

***random effects specification
**column 1
xtreg MinEffortP  leader $demographics $religious  if mleader==1 & treatment==1, re vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town RE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
**column 2
xtreg MinEffortP  leader $demographics $religious  if hleader==1 & treatment==1, re vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town RE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***ordered probit
**column 3
oprobit MinEffortP  leader $demographics $religious  if mleader==1 & treatment==1, vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext(Ordered probit, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
**column 4
oprobit MinEffortP  leader $demographics $religious  if hleader==1 & treatment==1,  vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Ordered probit, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

***control for whether you dislike a person of a different religion as neighbor
**column 5
areg MinEffortP  leader $demographics $religious nolike_diffrel if mleader==1 & treatment==1, absorb(townid_exp) vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town RE, FE, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No, Control for religious dislike, Yes) 
**column 6
areg MinEffortP  leader $demographics $religious nolike_diffrel if hleader==1 & treatment==1,  absorb(townid_exp) vce(cl unique_groupid)  
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town RE, FE, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No, Control for religious dislike, Yes) 
restore

preserve
gen umat = 10*townid_exp + matnumber
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
***dropping one town where we could not recruit full set of people, hence seating arrangements were different
drop if townid_exp==40

***Individual effort results, controlling for mat fixed effects
xi i.umat
**Column 7: Muslim leaders, Muslim individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==1 & muslim==1, vce(cl unique_groupid)  absorb(umat)
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Muslim Leaders, Muslim Employees") append addtext( Town-Mat FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 8: Muslim leader, Hindu individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==1 & muslim==0 , vce(cl unique_groupid)  absorb(umat)
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Muslim Leaders, Hindu Employees") append addtext( Town-Mat FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 9: Hindu leader, Muslim individuals
areg EffortP  leader $demographics $religious if treatment==1 & mleader==0 & muslim==1 , vce(cl unique_groupid)  absorb(umat)
outreg2 leader using "$path/tc1.xls", bdec(3) excel ctitle("Hindu Leaders, Muslim Employees") append addtext( Town-Mat FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 10: Hindu leader, Hindu individuals
areg EffortP  leader  $demographics $religious if treatment==1 & mleader==0 & muslim==0 , vce(cl unique_groupid)  absorb(umat)
outreg2 leader using  "$path/tc1.xls", bdec(3) excel ctitle("Hindu Leaders, Hindu Employees") append addtext( Town-Mat FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
restore


***********************************************************************************
**TC2: Policy Environments and Leader Effectiveness, Controlling for Gender of Puzzle Partner
***********************************************************************************

count
tab townid_exp
preserve

***dropping towns where we did not have the full 24 obs (cos people were matched up differently there)
keep if townid_exp!=1 & townid_exp!=18 & townid_exp!= 24 & townid_exp!= 33 & townid_exp!= 40


gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen leader_aa=leader*(treatment==2)
gen leader_contact=leader*(treatment==3)
gen leader_femalepartner=leader*female_puzzle_partner
gen triple=leader*female_puzzle_partner*(treatment==3)
gen contact_female=(treatment==3)*female_puzzle_partner

collapse (mean) MinEffortP mleader hleader leader triple leader_aa leader_contact leader_femalepartner female_puzzle_partner townid_exp treatment  $demographics  $experiment $religious, by(unique_groupid period)

cap erase "$path/tc2.xls"
cap erase "$path/tc2.txt"

**Column 1: interacted specification, Muslim leaders
areg MinEffortP  leader leader_aa leader_contact triple leader_femalepartner female_puzzle_partner  $demographics $religious if mleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2   leader leader_aa leader_contact triple leader_femalepartner female_puzzle_partner  using "$path/tc2.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 

**Column 2: interacted specification, Hindu leaders
areg MinEffortP    leader leader_aa leader_contact triple leader_femalepartner female_puzzle_partner $demographics $religious if hleader==1, vce(cl unique_groupid)  absorb(townid_exp)
outreg2   leader leader_aa leader_contact triple leader_femalepartner female_puzzle_partner using "$path/tc2.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, Yes, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, No) 
restore

/**
***********************************************************************************
**TC3: Conflict History and Policy Environments, Controlling for Leader Proposals
***********************************************************************************

preserve
collapse (mean) MinEffortP EffortP mleader hleader townid_exp treatment highconflict $demographics  $experiment $religious, by(unique_groupid period)
gen leader=0
replace leader=1 if period>4
label var leader "Leader (period>4)"
gen leader_aa=leader*(treatment==2)
gen leader_contact=leader*(treatment==3)

cap erase "$path/tc3.xls"
cap erase "$path/tc3.txt"


**Column 1: Muslim leaders, low conflict areas
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if mleader==1 & period>4 & highconflict==0, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/tc3.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 

**Column 2: Muslim leaders, high conflict areas
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if mleader==1 & period>4 & highconflict==1, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/tc3.xls", bdec(3) excel ctitle("Muslim Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 

**Column 3: Hindu leaders, low conflict areas
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if hleader==1 & period>4 & highconflict==0, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/tc3.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 

**Column 4: Hindu leaders, high conflict areas
reg MinEffortP leader_aa leader_contact  $demographics $religious $experiment if hleader==1 & period>4 & highconflict==1, vce(cl unique_groupid)  
outreg2 leader_aa leader_contact  using "$path/tc3.xls", bdec(3) excel ctitle("Hindu Leaders") append addtext( Town FE, No, Demographic Controls, Yes, Religious Controls, Yes, Experimental Controls, Yes) 
restore
***/
exit
